package com.allwees.bs.c.module.user.req;

import com.allwees.bs.core.model.constant.CacheName;
import com.allwees.bs.core.modelbase.req.Req;
import com.allwees.bs.core.modelbase.validate.ValidateItem;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Data
@EqualsAndHashCode(callSuper = true)
public class SendVerifyEmailReq extends Req {

    private VerifyEmailType verifyEmailType;

    private String email;

    @Override
    public ValidateItem[] getValidateItems() {
        return new ValidateItem[] {
                new ValidateItem(verifyEmailType == null, "verify email type can not be blank"),
                new ValidateItem(StringUtils.isBlank(email), "email can not be blank"),
        };
    }

    @Getter
    public enum VerifyEmailType {
        CHANGE_PWD(CacheName.USER_CHANGE_PWD_VERIFY_CODE),
        INIT_EMAIL(CacheName.USER_INIT_EMAIL_VERIFY_CODE)
        ;
        private String cacheName;

        VerifyEmailType(String cacheName) {
            this.cacheName = cacheName;
        }
    }
}

/**  修改邮箱情况
 *  1、无邮箱 【验证码】
 *  2、有邮箱 【验证密码】
 *
 *  修改密码
 *  1、默认密码
 *      (1) 有邮箱
 *      (2) 无邮箱
 *  2、有密码
 *      确认密码即可
 *
 *  发送邮箱验证码
 *      无邮箱时设置邮箱
 *      默认密码时是否发送邮件
 */

